package slim3.demo.controller.tpe;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;



public class ReadHTMLFile {
	
    public static void main(String[] args) throws Exception {
        
        //get revised flight information
//        ReadHTMLFile test = new ReadHTMLFile();
//        ArrayList<FlightBean> beans = test.getRevisedFlightInformation();
//        
//        for (int i=0; i<beans.size(); i++) {
//
//            System.out.println(beans.get(i).toString());
//        }
        
//        test.getTest();
        
//        System.out.println("test");
        
        ReadHTMLFile test = new ReadHTMLFile();
        ArrayList<FlightBean> beans = test.getTodayDeparture();
        
        for (int i=0; i<beans.size(); i++) {            
            System.out.println(beans.get(i).toString());
        }
        
    }
    
        
    
    /**
     * get revised flight information
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getRevisedFlightInformation() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=P&apcode=null&dayindex=4&viewall=yes&cnid=508");
//            URL tsa = new URL("http://210.241.14.104/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=P&apcode=null&dayindex=4&viewall=yes&cnid=508");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             String k = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     k = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanRevisedFlightInformation(a,b,c,d,e,f,g,h,i,j,k);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    public FlightBean addFlightBeanRevisedFlightInformation(String a, String b,
            String c, String d, String e, String f, String g, String h,
            String i, String j, String k) {
        
        String t;
        FlightBean bean = new FlightBean();
        
        //arrivalOrDeparture
        //<td><div align="center">Arrival</div></td>
        t = a;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setArrivalOrDeparture(t);
        
        //scheduledTime
        //<td width="1%" nowrap="nowrap"><div align="center">08/10<br>21:40</div></td>
        t = b;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        t = t.substring(0, 5) + " " + t.substring(9, 14);
        bean.setScheduledTime(t);
        
        //expectedTime
        //<td width="1%" nowrap="nowrap"><div align="center">08/11<br>04:25</div></td>
        t = c;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        t = t.substring(0, 5) + " " + t.substring(9, 14);
        bean.setExpectedTime(t);
        
        //airline
        //<td width="1%" nowrap="nowrap"><div align="center">CI</div></td>
        t = d;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setAirline(t);
        
        //flightNo
        //<td width="1%" nowrap="nowrap"><div align="center">19</div></td>
        t = e;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setFlightNo(t);
        
        //via
        //<td><div align="center">Osaka Kansai</div></td>
        t = f;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setVia("");
        } else {
            bean.setVia(t);
        }
        
        //origin or destination
        //<td width="1%" nowrap="nowrap"><div align="center">New York</div></td>
        t = g;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setOriginOrDestination(t);
                
        //terminal
        //<td width="1%"><div align="center">2   </div></td>
        t = h;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setTerminal(t);
        
        //gate
        //<td width="1%"><div align="center">-</div></td>
        t = i;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setGate("");
        } else {
            bean.setGate(t);
        }
        
        //planeType
        //<td width="1%" nowrap="nowrap"><div align="center">-</div></td>
        t = j;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setPlaneType("");
        } else {
            bean.setPlaneType(t);
        }
        
        //status
        //<td nowrap="nowrap">SCHEDULE CHANGE</td>
        t = k;
        t = t.substring(t.indexOf("ap\">")+4, t.indexOf("</t")).trim();
        bean.setStatus(t);
                

        return bean;
        
  }
    
    
    /**
     * get today departure
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getTodayDeparture() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=D&airtype=P&apcode=null&dayindex=2&viewall=yes&cnid=510");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    public FlightBean addFlightBeanGeneral(String a, String b,
            String c, String d, String e, String f, String g, String h,
            String i, String j) {
        
        String t;
        FlightBean bean = new FlightBean();

        
        //scheduledTime
        //<td width="1%" nowrap="nowrap"><div align="center">08/10<br>21:40</div></td>
        t = a;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        t = t.substring(0, 5) + " " + t.substring(9, 14);
        bean.setScheduledTime(t);
        
        //expectedTime
        //<td width="1%" nowrap="nowrap"><div align="center">08/11<br>04:25</div></td>
        t = b;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        t = t.substring(0, 5) + " " + t.substring(9, 14);
        bean.setExpectedTime(t);
        
        //airline
        //<td width="1%" nowrap="nowrap"><div align="center">CI</div></td>
        t = c;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setAirline(t);
        
        //flightNo
        //<td width="1%" nowrap="nowrap"><div align="center">19</div></td>
        t = d;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setFlightNo(t);
        
        //via
        //<td><div align="center">Osaka Kansai</div></td>
        t = e;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setVia("");
        } else {
            bean.setVia(t);
        }
        
        //origin or destination
        //<td width="1%" nowrap="nowrap"><div align="center">New York</div></td>
        t = f;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setOriginOrDestination(t);
                
        //terminal
        //<td width="1%"><div align="center">2   </div></td>
        t = g;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        bean.setTerminal(t);
        
        //gate
        //<td width="1%"><div align="center">-</div></td>
        t = h;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setGate("");
        } else {
            bean.setGate(t);
        }
        
        //planeType
        //<td width="1%" nowrap="nowrap"><div align="center">-</div></td>
        t = i;
        t = t.substring(t.indexOf("er\">")+4, t.indexOf("</d")).trim();
        if (t.equals("-")) {
            bean.setPlaneType("");
        } else {
            bean.setPlaneType(t);
        }
        
        //status
        //<td nowrap="nowrap">SCHEDULE CHANGE</td>
        t = j;
        t = t.substring(t.indexOf("ap\">")+4, t.indexOf("</t")).trim();
        bean.setStatus(t);
                

        return bean;
        
    }
    
    
    /**
     * get today arrival
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getTodayArrival() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=P&apcode=null&dayindex=2&viewall=yes&cnid=706");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get tomorrow departure
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getTomorrowDeparture() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=D&airtype=P&apcode=null&dayindex=3&viewall=yes&cnid=512");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get tomorrow arrival
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getTomorrowArrival() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=P&apcode=null&dayindex=3&viewall=yes&cnid=930");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get yesterday departure
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getYesterdayDeparture() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=D&airtype=P&apcode=null&dayindex=1&viewall=yes&cnid=642");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get yesterday arrival
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getYesterdayArrival() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=P&apcode=null&dayindex=1&viewall=yes&cnid=1176");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
                                 } else if ( !str.trim().contains("<td nowrap=\"nowrap\">") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get cargo departure
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getCargoDeparture() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=D&airtype=C&apcode=null&dayindex=2&viewall=yes&cnid=1178");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
        
    
    /**
     * get cargo arrival
     * @return
     * @throws Exception
     */
    public ArrayList<FlightBean> getCargoArrival() throws Exception{

        ArrayList<FlightBean> all = new ArrayList<FlightBean>();
        FlightBean bean = null;
        

        try {

          
            /**
             * read from URL
             */
            URL tsa = new URL("http://www.taoyuan-airport.com/english/schedule_e.jsp?airline=null&area=null&apio=A&airtype=C&apcode=null&dayindex=2&viewall=yes&cnid=1180");
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

  
            /**
             * process code below
             */
            String str;
            boolean finished = false;

                while ( ((str = in.readLine()) != null) && !finished) {
                    
                    if (str.trim().equals("<DIV align=center>Status </DIV></TH></tr>")) {
                                        
                     while ((str = in.readLine()) != null) {
                         
                         if (str.trim().equals("</TBODY></TABLE></td></tr>")) {
                             finished = true;
                             break;
                         }
                         
                         
                         if (str.contains("<tr class=\"title_bg_02")) {
                             String a = "";
                             String b = "";
                             String c = "";
                             String d = "";
                             String e = "";
                             String f = "";
                             String g = "";
                             String h = "";
                             String i = "";
                             String j = "";
                             boolean done = false;
                             
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                 } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                 } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     a = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     b = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore logo images
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     //ignore full airline names
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     c = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     d = str.trim();
                                     done = true;
                                 }
                             }

                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     e = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     f = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     g = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     h = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     i = str.trim();
                                     done = true;
                                 }
                             }
                             
                             done = false;
                             str = in.readLine();
                             while (str != null && !done) {
                                 if (str.trim().equals("")) {
                                     str = in.readLine();
//                                   } else if ( !str.trim().contains("<div align=\"center\">") ) {
                                   } else if ( !str.trim().contains("<td") ) {
                                     str = in.readLine();
                                 } else {
                                     j = str.trim();
                                     done = true;
                                 }
                             }
                             
                             
                             bean = addFlightBeanGeneral(a,b,c,d,e,f,g,h,i,j);
                             
                             all.add(bean);
                             
                             
                         }
         
                     }
                     
                }
    
            }
            
            in.close();
            
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return all;
            
    }
    
    

}
